package com.vesper.mysdk

import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import android.util.Log
import android.view.View

class MainActivity : AppCompatActivity(), MCallback {
    val TAG:String = "MainActivity"
    lateinit var msdk: MSDK
    lateinit var wpv: WordParticleView
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_main)
        initView()
    }
    fun initView(){
        wpv = findViewById(R.id.wpv)
    }
    fun call_init(view: View) {
        msdk = MSDK.Companion.initSDK("123", "123", this)!!
        wpv.setText("你好")
    }

    fun call_login(view: View) {
        msdk.login("123", "123")
    }


    fun call_logout(view: View) {
        msdk.logout()
    }

    fun call_get_status(view: View) {
        var status = msdk.getLoginStatus()
        Log.i(TAG, "call_get_status: $status")
    }

    fun call_destroy(view: View) {
        msdk.destroySDK()
    }

    override fun onDestroy(res: Boolean, reason: Int) {
        Log.i(TAG, "onDestroy: res = $res,reason = $reason")
    }

    override fun onInit(res: Boolean, @MSDK.Companion.MReason reason: Int) {
        Log.i(TAG, "onInit:  res = $res,Reason = $reason")
    }

    override fun onLogin(res: Boolean, @MSDK.Companion.MReason reason: Int) {
        Log.i(TAG, "onLogin: res = $res,Reason = $reason")
    }

    override fun onLoginStatusChanged(
        @MSDK.Companion.SDKStatus oldStatus: Int, @MSDK.Companion.SDKStatus newStatus: Int
    ) {
        when (newStatus) {
            MSDK.STATUS_NOT_INIT -> Log.i(TAG, "onLoginStatusChanged:  STATUS_NOT_INIT")
            MSDK.STATUS_INITED -> Log.i(TAG, "onLoginStatusChanged:  STATUS_INITED")
            MSDK.STATUS_NOT_LOGIN -> Log.i(TAG, "onLoginStatusChanged:  STATUS_NOT_LOGIN")
            MSDK.STATUS_LOGINED -> Log.i(TAG, "onLoginStatusChanged:  STATUS_LOGINED")
            else -> return
        }

    }

    override fun onLogout(res: Boolean, @MSDK.Companion.MReason reason: Int) {
        Log.i(TAG, "onLogout: res= $res,reason = $reason")
    }


}